﻿using System;
using System.Data;
using System.Collections.Generic;
using NetDiskPRJ.Common;
using NetDiskPRJ.Model;
namespace NetDiskPRJ.BLL
{
    /// <summary>
    /// 权限用户对照表
    /// </summary>
    public partial class PrvUser
    {
        public PrvUser()
        { }
        /// <summary>
        /// 是否存在该记录
        /// <creator>wangl</creator>
        /// <date>2013-02-17</date> 
        /// </summary>
        public bool Exists(string logID)
        {
            NetDiskPRJ.DAL.PrvUser prvUserDAL = new NetDiskPRJ.DAL.PrvUser();
            return prvUserDAL.Exists(logID);
        }

                /// <summary>
        /// 删除一条数据
        /// <creator>zhongyl</creator>
        /// <date>2013-02-17</date>
        /// </summary>
        public void Delete(string FLogID)
        {
            NetDiskPRJ.DAL.PrvUser prvUserDAL = new NetDiskPRJ.DAL.PrvUser();
            prvUserDAL.Delete(FLogID);
        }

        public void SavePrvUser(List<Model.PrvUser> AddPrvUser, List<Model.PrvUser> UpdatePrvUser, List<Model.PrvUserGroup> PrvUserGroupList, List<Model.PrvAllowData> PrvAllowDataList)
        {

            NetDiskPRJ.DAL.PrvUser prvUserDAL = new NetDiskPRJ.DAL.PrvUser();
            prvUserDAL.SavePrvUser(AddPrvUser, UpdatePrvUser, PrvUserGroupList, PrvAllowDataList);
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List<NetDiskPRJ.Model.PrvUser> GetModelList(string strWhere)
        {
            NetDiskPRJ.DAL.PrvUser prvUserDAL = new NetDiskPRJ.DAL.PrvUser();
            DataSet ds = prvUserDAL.GetList(strWhere);
            return DataTableToList(ds.Tables[0]);
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List<NetDiskPRJ.Model.PrvUser> DataTableToList(DataTable dt)
        {
            NetDiskPRJ.DAL.PrvUser prvUserDAL = new NetDiskPRJ.DAL.PrvUser();
            List<NetDiskPRJ.Model.PrvUser> modelList = new List<NetDiskPRJ.Model.PrvUser>();
            int rowsCount = dt.Rows.Count;
            if (rowsCount > 0)
            {
                NetDiskPRJ.Model.PrvUser model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = prvUserDAL.DataRowToModel(dt.Rows[n]);
                    if (model != null)
                    {
                        modelList.Add(model);
                    }
                }
            }
            return modelList;
        }

                /// <summary>
        /// 更新密码
        /// <creator>zhongyl</creator>
        /// <date>2013-02-17</date>
        /// </summary>
        /// <param name="logid">登录ID</param>
        /// <param name="password">MD5加密后的密码</param>
        /// <returns></returns>
        public bool UpdatePassword(string logid, string password)
        {
            NetDiskPRJ.DAL.PrvUser prvUserDAL = new NetDiskPRJ.DAL.PrvUser();
            return prvUserDAL.UpdatePassword(logid, password);
        }
        /// <summary>
        /// 获取用户密码
        /// <creator>wangl</creator>
        /// <date>2013-02-17</date> 
        /// </summary>
        /// <param name="logid">登录ID</param>
        /// <returns></returns>
        public string GetUserPassword(string logID)
        {
            NetDiskPRJ.DAL.PrvUser prvUserDAL = new NetDiskPRJ.DAL.PrvUser();
            return prvUserDAL.GetUserPassword(logID);
        }
        /// <summary>
        /// 更新登录相关信息
        /// <creator>wangl</creator>
        /// <date>2013-02-17</date>
        /// </summary>
        /// <param name="logid">登录ID</param>
        /// <param name="version">版本信息</param>
        /// <param name="ipaddr">IP地址</param>
        public void UpdateLoginInfo(string logID, string version, string ipaddr)
        {
            NetDiskPRJ.DAL.PrvUser prvUserDAL = new NetDiskPRJ.DAL.PrvUser();
            prvUserDAL.UpdateLoginInfo(logID, version, ipaddr);
        }
        /// <summary>
        /// 获取用户名
        /// <creator>wangl</creator>
        /// <date>2013-02-17</date>
        /// </summary>
        /// <param name="logid">登录ID</param>
        /// <returns></returns>
        public string GetUserFullname(string logID)
        {
            NetDiskPRJ.DAL.PrvUser prvUserDAL = new NetDiskPRJ.DAL.PrvUser();
            return prvUserDAL.GetUserFullname(logID);
        }


        /// <summary>
        /// 获取工作量报告
        /// <creator>sunlj</creator>
        /// <date>2013-08-02</date>
        /// </summary>
        /// <param name="beginDate"></param>
        /// <param name="endDate"></param>
        /// <returns></returns>
        public DataSet GetKPIReport(string beginDate, string endDate)
        {
            NetDiskPRJ.DAL.PrvUser prvUserDAL = new NetDiskPRJ.DAL.PrvUser();
            return prvUserDAL.GetKPIReport(beginDate, endDate);
        }
    }
}

